package com.meihua.baoleyi.net;

import android.content.Context;
import android.util.Log;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.meihua.baoleyi.bean.BankInfo;
import com.meihua.baoleyi.bean.BankListResult;
import com.meihua.baoleyi.bean.BaseBean;
import com.meihua.baoleyi.utils.JsonUtils;
import com.meihua.baoleyi.utils.LmsConstant;
import com.meihua.baoleyi.utils.SharedPreUtils;
import com.meihua.baoleyi.utils.ToastUtil;
import com.meihua.baoleyi.utils.UrlContants;
import com.meihua.baoleyi.view.IBankView;

import java.util.List;
import okhttp3.Call;
import okhttp3.Response;

import static com.meihua.baoleyi.utils.JsonUtils.parse;

/**
 * Created by liming  on 2017/10/18
 */

public class BankPresenter {

    private IBankView mBankView;

    private BankListResult result;

    private List<BankInfo> mBankInfoList;

    private Context mContext;

    public BankPresenter(Context context, IBankView view) {
        mBankView = view;
        mContext = context;
    }

    public void listBank() {

    }

    public void cash(String m,BankInfo b) {

        OkGo.post(UrlContants.HOST + "Api/Myself/withdraw")
                .params("user_id", b.getUser_id())
                .params("wm_money",m)
                .params("wm_real_name",b.getReal_name())
                .params("wm_banks_name",b.getBanks_name())
                .params("wm_bank_card",b.getBanks_card())
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
//                        Log.e("asefjasdfa",s+"");
                        BaseBean b = JsonUtils.parse(mContext,s, BaseBean.class);
                        mBankView.onCash(b);
                    }
                });
    }

}
